﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Axelerate.Silverlight3D.Media;
using Axelerate.Silverlight3D.Media.Media3D;
using System.ComponentModel;

namespace Axelerate3DEngineUseSamples
{
    public partial class PrimitiveMeshBuilderTest : UserControl
    {
        public PrimitiveMeshBuilderTest()
        {
            
            InitializeComponent();
           
            GeometryModel3D model = (viewport.Children[0] as ModelVisual3D).Content as GeometryModel3D;
            //model.Geometry = PrimitiveMeshBuilder.CreateBox(new Rect3D(-1, -1, -1, 1, 4, 1));
            model.Geometry = PrimitiveMeshBuilder.CreateLine3D(new Point3D(-3, 0, 0), new Point3D(3, 0, 0), 0.05, new Vector3D(0, 1, 0));
            PrimitiveMeshBuilder.AddLine3DToMesh(model.Geometry as MeshGeometry3D, new Point3D(0, 0, -3), new Point3D(0, 0, 3), 0.05, new Vector3D(0, 1, 0)); 
            Storyboard.SetTarget(anim1, ((viewport.Children[0] as ModelVisual3D).Transform as RotateTransform3D).Rotation as AxisAngleRotation3D);
            
            anim1.Begin();
            
        }

        private void anim1_Completed(object sender, EventArgs e)
        {
            //GeometryModel3D model = (viewport.Children[0] as ModelVisual3D).Content as GeometryModel3D;
            (((viewport.Children[0] as ModelVisual3D).Transform as RotateTransform3D).Rotation as AxisAngleRotation3D).Angle += 3;
            ((Storyboard)sender).Begin();
        }
    }
}
